package com.tinyideatech.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tinyideatech.system.entity.MallMember;
import com.tinyideatech.system.mapper.MallMemberMapper;
import com.tinyideatech.system.service.IMallMemberService;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhangy-5
 * @date 2019-08-29
 */
@Service
public class MallMemberServiceImpl extends ServiceImpl<MallMemberMapper, MallMember> implements IMallMemberService {

    @Override
    public void changeStatus(MallMember mallMember) {


    }


    public MallMember saveWxUser(WxMpUser wxMpUser, MallMember user, String deviceId)
    {
        user.setSubscribe(wxMpUser.getSubscribe());
        user.setOpenId(wxMpUser.getOpenId());
        user.setNickname(wxMpUser.getNickname().replaceAll("[\\ud800-\\udfff]", "").trim());
        user.setSex(wxMpUser.getSex() + "");
        user.setCity(wxMpUser.getCity());
        user.setProvince(wxMpUser.getProvince());
        user.setCountry(wxMpUser.getCountry());
        user.setHeadImgUrl(wxMpUser.getHeadImgUrl());
        user.setSubscribeTime(wxMpUser.getSubscribeTime());
        user.setRemark(wxMpUser.getRemark());
        user.setGroupId(wxMpUser.getGroupId());
        save(user);
        return user;
    }

}
